package org.jeecg.modules.service.impl;

import org.jeecg.modules.service.IFileService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.File;

@Service
public class FileServiceImpl implements IFileService {
    @Value("${jeecg.path.upload}")
    private String uploadPath;

    @Override
    public boolean deleteFileByRelativePath(String relativePath) {
        File file = new File(uploadPath, relativePath);
        try {
            if (file.isFile() && file.exists())
                return file.delete();
            // 如果不存在认为删除成功
        } catch (Exception e) {
            return false;
        }
        return true;
    }
}
